#ifndef LINK_H
#define LINK_H

#include <QDeclarativeItem>

class Link : public QDeclarativeItem
{
    Q_OBJECT
    Q_PROPERTY(QDeclarativeItem* a READ a WRITE setA NOTIFY aChanged)
    Q_PROPERTY(QDeclarativeItem* b READ b WRITE setB NOTIFY bChanged)
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
    Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged )
    Q_PROPERTY(int aPoint READ aPoint WRITE setAPoint NOTIFY aPointChanged)

public:
    explicit Link(QDeclarativeItem *parent = 0);
    explicit Link(const Link& other);
    explicit Link(QDeclarativeItem &a, QDeclarativeItem &b, int aPoint = 0);

    Q_INVOKABLE QDeclarativeItem* a() const;
    Q_INVOKABLE QDeclarativeItem* b() const;

    Q_INVOKABLE QColor color() const;
    Q_INVOKABLE int lineWidth() const;
    Q_INVOKABLE int aPoint() const;

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);

    //virtual ~Link();

signals:
    void aChanged();
    void bChanged();
    void colorChanged();
    void lineWidthChanged();
    void aPointChanged();

public slots:
    void redraw();

    void setA(QDeclarativeItem *a);
    void setB(QDeclarativeItem *b);
    void setColor(QColor color);
    void setLineWidth(int lineWidth);
    void setAPoint(int aPoint);

protected:
    QDeclarativeItem *mA, *mB;
    int mAPoint;

    QColor mColor;
    int mPenWidth;

private slots:
    void aDestroyed();
    void bDestroyed();

private:
    void init();
};

#endif // LINK_H
